#!/bin/bash

set -o pipefail -e
export PRELAUNCH_OUT="/export/bigdata/hadoop/logs/userlogs/application_1749212209307_0015/container_e16_1749212209307_0015_01_000001/prelaunch.out"
exec >"${PRELAUNCH_OUT}"
export PRELAUNCH_ERR="/export/bigdata/hadoop/logs/userlogs/application_1749212209307_0015/container_e16_1749212209307_0015_01_000001/prelaunch.err"
exec 2>"${PRELAUNCH_ERR}"
echo "Setting up env variables"
export JAVA_HOME=${JAVA_HOME:-"/usr"}
export HADOOP_COMMON_HOME=${HADOOP_COMMON_HOME:-"/export/bigdata/hadoop"}
export HADOOP_HDFS_HOME=${HADOOP_HDFS_HOME:-"/export/bigdata/hadoop"}
export HADOOP_CONF_DIR=${HADOOP_CONF_DIR:-"/export/bigdata/hadoop/etc/hadoop"}
export HADOOP_YARN_HOME=${HADOOP_YARN_HOME:-"/export/bigdata/hadoop"}
export HADOOP_HOME=${HADOOP_HOME:-"/export/bigdata/hadoop"}
export PATH=${PATH:-"/usr/local/bin:/usr/bin:/export/bigdata/hadoop/bin:/export/bigdata/hadoop/sbin:/usr/lib/jvm/jdk/bin"}
export LANG=${LANG:-"zh_CN.UTF-8"}
export HADOOP_TOKEN_FILE_LOCATION="/export/bigdata/hadoop/tmp/nm-local-dir/usercache/bigdata/appcache/application_1749212209307_0015/container_e16_1749212209307_0015_01_000001/container_tokens"
export CONTAINER_ID="container_e16_1749212209307_0015_01_000001"
export NM_PORT="9177"
export NM_HOST="hadoop0010"
export NM_HTTP_PORT="8042"
export LOCAL_DIRS="/export/bigdata/hadoop/tmp/nm-local-dir/usercache/bigdata/appcache/application_1749212209307_0015"
export LOCAL_USER_DIRS="/export/bigdata/hadoop/tmp/nm-local-dir/usercache/bigdata/"
export LOG_DIRS="/export/bigdata/hadoop/logs/userlogs/application_1749212209307_0015/container_e16_1749212209307_0015_01_000001"
export USER="bigdata"
export LOGNAME="bigdata"
export HOME="/home/"
export PWD="/export/bigdata/hadoop/tmp/nm-local-dir/usercache/bigdata/appcache/application_1749212209307_0015/container_e16_1749212209307_0015_01_000001"
export LOCALIZATION_COUNTERS="229512910,0,4,0,5536"
export JVM_PID="$$"
export NM_AUX_SERVICE_mapreduce_shuffle="AAA0+gAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="
export APPLICATION_WEB_PROXY_BASE="/proxy/application_1749212209307_0015"
export JAR_FILE_PATH="hdfs://unicom-cluster/user/bigdata/yarn-client-test-1.0-SNAPSHOT.jar"
export CLASSPATH="$CLASSPATH:./*:/export/bigdata/hadoop/etc/hadoop:/export/bigdata/hadoop/share/hadoop/common/lib/*:/export/bigdata/hadoop/share/hadoop/common/*:/export/bigdata/hadoop/share/hadoop/hdfs:/export/bigdata/hadoop/share/hadoop/hdfs/lib/*:/export/bigdata/hadoop/share/hadoop/hdfs/*:/export/bigdata/hadoop/share/hadoop/mapreduce/*:/export/bigdata/hadoop/share/hadoop/yarn:/export/bigdata/hadoop/share/hadoop/yarn/lib/*:/export/bigdata/hadoop/share/hadoop/yarn/*:./log4j.properties"
export APP_SUBMIT_TIME_ENV="1751359838453"
export MALLOC_ARENA_MAX="4"
echo "Setting up job resources"
ln -sf -- "/export/bigdata/hadoop/tmp/nm-local-dir/usercache/bigdata/appcache/application_1749212209307_0015/filecache/11/javaOpts" "javaOpts"
ln -sf -- "/export/bigdata/hadoop/tmp/nm-local-dir/usercache/bigdata/appcache/application_1749212209307_0015/filecache/10/AppMaster.jar" "AppMaster.jar"
ln -sf -- "/export/bigdata/hadoop/tmp/nm-local-dir/usercache/bigdata/appcache/application_1749212209307_0015/filecache/12/shellArgs" "shellArgs"
ln -sf -- "/export/bigdata/hadoop/tmp/nm-local-dir/usercache/bigdata/filecache/10/yarn-client-test-1.0-SNAPSHOT.jar" "demo"
echo "Copying debugging information"
# Creating copy of launch script
cp "launch_container.sh" "/export/bigdata/hadoop/logs/userlogs/application_1749212209307_0015/container_e16_1749212209307_0015_01_000001/launch_container.sh"
chmod 640 "/export/bigdata/hadoop/logs/userlogs/application_1749212209307_0015/container_e16_1749212209307_0015_01_000001/launch_container.sh"
# Determining directory contents
echo "ls -l:" 1>"/export/bigdata/hadoop/logs/userlogs/application_1749212209307_0015/container_e16_1749212209307_0015_01_000001/directory.info"
ls -l 1>>"/export/bigdata/hadoop/logs/userlogs/application_1749212209307_0015/container_e16_1749212209307_0015_01_000001/directory.info"
echo "find -L . -maxdepth 5 -ls:" 1>>"/export/bigdata/hadoop/logs/userlogs/application_1749212209307_0015/container_e16_1749212209307_0015_01_000001/directory.info"
find -L . -maxdepth 5 -ls 1>>"/export/bigdata/hadoop/logs/userlogs/application_1749212209307_0015/container_e16_1749212209307_0015_01_000001/directory.info"
echo "broken symlinks(find -L . -maxdepth 5 -type l -ls):" 1>>"/export/bigdata/hadoop/logs/userlogs/application_1749212209307_0015/container_e16_1749212209307_0015_01_000001/directory.info"
find -L . -maxdepth 5 -type l -ls 1>>"/export/bigdata/hadoop/logs/userlogs/application_1749212209307_0015/container_e16_1749212209307_0015_01_000001/directory.info"
echo "Launching container"
exec /bin/bash -c "$JAVA_HOME/bin/java -Xmx1024m me.wang.ApplicationMaster --container_memory 1024 --container_vcores 1 --memory_overhead 512 --num_containers 3 --priority 0 1>/export/bigdata/hadoop/logs/userlogs/application_1749212209307_0015/container_e16_1749212209307_0015_01_000001/AppMaster.stdout 2>/export/bigdata/hadoop/logs/userlogs/application_1749212209307_0015/container_e16_1749212209307_0015_01_000001/AppMaster.stderr "
